﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using LeePong.Game.Shapes;

namespace LeePong.Game.Entities
{
    public class Score
    {
        public FixedRectangle Rect;
        public int Points;
        public int BaseGlow;
        public int Glow;
        private int glowSleep;

        public Score(Rectangle rect)
        {
            this.Rect = new FixedRectangle(rect);
            this.BaseGlow = (int)Math.Round(0.4 * Rect.Width);

        }
        public void Increment()
        {
            this.Points++;
            this.DoGlow();
        }

        public void DoGlow()
        {
            this.Glow = BaseGlow;
            var thread = new Thread(() =>
                {
                    GlowAction();
                });
            thread.Start();
        }

        private void GlowAction()
        {
            var i = 0;
            while (this.Glow > 0)
            {
                i++;
                this.Glow = (int)Math.Floor(this.Glow - (20.0 / this.Glow));
                Thread.Sleep(15);
            }
        }
    }
}
